<?php

namespace app\common\repository\articleComment;

use app\common\model\article\ArticleComment as ArticleCommentModel;

class R
{
    public function __construct(
        ArticleCommentModel $articleCommentModel
    )
    {
        $this->articleCommentModel = $articleCommentModel;
    }

    public function getArticleComment($cond)
    {
        return ArticleCommentModel::where($cond)
            ->with(['createUser' => ['profile'], 'referUser' => ['profile']])
            ->find();
    }

    public function getArticleCommentsWithPage($cond, $order, $page)
    {
        $count = count(ArticleCommentModel::where($cond)
            ->select());
        $list = ArticleCommentModel::where($cond)
            ->with(['createUser' => ['profile'], 'referUser' => ['profile']])
            ->order($order)
            ->limit($page['size'])
            ->page($page['index'])
            ->select();
        return ['count' => $count, 'list' => $list];
    }
}
